//
//  SelectFactoryLineTableViewCell.m
//  Rail
//
//  Created by huyuchen on 2018/3/19.
//  Copyright © 2018年 Hychen. All rights reserved.
//

#import "SelectFactoryLineTableViewCell.h"
#import "LinePointDetailView.h"
@interface SelectFactoryLineTableViewCell ()

@property (nonatomic, strong) LinePointDetailView *linePath;

@end
@implementation SelectFactoryLineTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setupLinePathWithColor:(UIColor *)lineColor {
    if (self.linePath.superview) {
        [self.linePath removeFromSuperview];
    }
    LinePointDetailView *view = [[LinePointDetailView alloc] initWithLineColor:lineColor];
    WeakSelf_bb
    [view setBlockClickButton:^(id obj) {
        if (weakSelf.BlockClickButton) {
            weakSelf.BlockClickButton(obj,weakSelf.cellFoldModel);
        }
    }];
    self.linePath = view;
    [self.contentView addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
}

- (void)setCellFoldModel:(SelectFactoryFoldCellModel *)cellFoldModel {
    if ([_cellFoldModel isEqual:cellFoldModel]) {
        return;
    }
    _cellFoldModel = cellFoldModel;
    FactoryTreeLineModel *lineModel = cellFoldModel.obj;
    [self setupLinePathWithColor:[BMUtils colorWithString:lineModel.line_color]];
    self.linePath.stationArray = lineModel.station_list;
}


+ (CGFloat)heightForSelectFactoryLineCell:(NSInteger)count {
    return [LinePointDetailView heightForLinePointViewWithPointCount:count showBottonLine:YES];
}

@end
